{{ if .Site.Params.enableDarkMode }}
    {{ with .Site.Params.defaultTheme | default "light" }}
        {{ if eq . "light" }}
            {{ $.Scratch.Set "text" "🌞" }}
        {{ else }}
            {{ $.Scratch.Set "text" "🌙" }}
        {{ end }}
        {{ $text := $.Scratch.Get "text" }}
        {{- $.Scratch.Delete "hide" -}}
        {{- if or (and $.IsHome $.Site.Params.hideThemeToggleInHome) (and (not $.IsHome) $.Site.Params.hideThemeToggle) -}}
            {{- $.Scratch.Set "hide" true -}}
        {{- end -}}
        {{- $hide := $.Scratch.Get "hide" -}}
        <div id="theme-switcher"{{ if $hide }} data-hide="true"{{ end }}>{{ $text }}</div>
    {{ end }}
{{ end }}
